linux: scan DMI early
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 5 Mar 2007 15:46:33 +0000 (15:46 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 5 Mar 2007 15:46:33 +0000 (15:46 +0000)
While shuffling quite a few things around, this gets us closer to
native, which clearly had a reason to do the DMI scan early.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c
linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/io.h

index b2e8832b85fefa3ced087ab1ba7c2df5a4cce737..bd13dbdade21d7ae44641b9b6d0de072cba03691 100644 (file)
@@ -374,8 +374,6 @@ void iounmap(volatile void __iomem *addr)
 }
 EXPORT_SYMBOL(iounmap);
 
-#ifdef __i386__
-
 void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
 {
        unsigned long offset, last_addr;
@@ -443,5 +441,3 @@ void __init bt_iounmap(void *addr, unsigned long size)
                --nrpages;
        }
 }
-
-#endif /* __i386__ */
index f286359fd1f448db97e4eeec89d6f823a04aa559..e6aa3ce1b87385f5effba72471dd9b56490f43fc 100644 (file)
@@ -676,7 +676,8 @@ void __init setup_arch(char **cmdline_p)
 
        init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
 
-       /* dmi_scan_machine(); */
+       if (is_initial_xendomain())
+               dmi_scan_machine();
 
 #ifdef CONFIG_ACPI_NUMA
        /*
@@ -1627,13 +1628,6 @@ struct seq_operations cpuinfo_op = {
        .show = show_cpuinfo,
 };
 
-static int __init run_dmi_scan(void)
-{
-       dmi_scan_machine();
-       return 0;
-}
-core_initcall(run_dmi_scan);
-
 #if defined(CONFIG_INPUT_PCSPKR) || defined(CONFIG_INPUT_PCSPKR_MODULE)
 #include <linux/platform_device.h>
 static __init int add_pcspkr(void)
index 663df7b215e9f281c0cc6ef12fe500fe2ce6270e..6db9be2317a57d1d38ab8cac5c351c4d505a0dec 100644 (file)
@@ -214,7 +214,11 @@ static __init void *spp_getpage(void)
        void *ptr;
        if (after_bootmem)
                ptr = (void *) get_zeroed_page(GFP_ATOMIC); 
-       else
+       else if (start_pfn < table_end) {
+               ptr = __va(start_pfn << PAGE_SHIFT);
+               start_pfn++;
+               memset(ptr, 0, PAGE_SIZE);
+       } else
                ptr = alloc_bootmem_pages(PAGE_SIZE);
        if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
                panic("set_pte_phys: cannot allocate page data %s\n", after_bootmem?"after bootmem":"");
@@ -438,17 +442,34 @@ static inline int make_readonly(unsigned long paddr)
        return readonly;
 }
 
+#ifndef CONFIG_XEN
 /* Must run before zap_low_mappings */
 __init void *early_ioremap(unsigned long addr, unsigned long size)
 {
-       return ioremap(addr, size);
+       unsigned long map = round_down(addr, LARGE_PAGE_SIZE);
+
+       /* actually usually some more */
+       if (size >= LARGE_PAGE_SIZE) {
+               printk("SMBIOS area too long %lu\n", size);
+               return NULL;
+       }
+       set_pmd(temp_mappings[0].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
+       map += LARGE_PAGE_SIZE;
+       set_pmd(temp_mappings[1].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
+       __flush_tlb();
+       return temp_mappings[0].address + (addr & (LARGE_PAGE_SIZE-1));
 }
 
 /* To avoid virtual aliases later */
 __init void early_iounmap(void *addr, unsigned long size)
 {
-       iounmap(addr);
+       if ((void *)round_down((unsigned long)addr, LARGE_PAGE_SIZE) != temp_mappings[0].address)
+               printk("early_iounmap: bad address %p\n", addr);
+       set_pmd(temp_mappings[0].pmd, __pmd(0));
+       set_pmd(temp_mappings[1].pmd, __pmd(0));
+       __flush_tlb();
 }
+#endif
 
 static void __meminit
 phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
@@ -646,9 +667,9 @@ static void __init extend_init_mapping(unsigned long tables_space)
        }
 }
 
-static void __init find_early_table_space(unsigned long end)
+static unsigned long __init find_early_table_space(unsigned long end)
 {
-       unsigned long puds, pmds, ptes, tables
+       unsigned long puds, pmds, ptes, tables, fixmap_tables;
 
        puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
        pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
@@ -658,7 +679,16 @@ static void __init find_early_table_space(unsigned long end)
                round_up(pmds * 8, PAGE_SIZE) + 
                round_up(ptes * 8, PAGE_SIZE); 
 
-       extend_init_mapping(tables);
+       /* Also reserve pages for fixmaps that need to be set up early.
+        * Their pud is shared with the kernel pud.
+        */
+       pmds = (PMD_SIZE - 1 - FIXADDR_START) >> PMD_SHIFT;
+       ptes = (PTE_SIZE - 1 - FIXADDR_START) >> PAGE_SHIFT;
+
+       fixmap_tables = round_up(pmds * 8, PAGE_SIZE) +
+               round_up(ptes * 8, PAGE_SIZE);
+
+       extend_init_mapping(tables + fixmap_tables);
 
        table_start = start_pfn;
        table_end = table_start + (tables>>PAGE_SHIFT);
@@ -666,6 +696,8 @@ static void __init find_early_table_space(unsigned long end)
        early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
                end, table_start << PAGE_SHIFT,
                (table_start << PAGE_SHIFT) + tables);
+
+       return table_end + (fixmap_tables>>PAGE_SHIFT);
 }
 
 /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
@@ -673,7 +705,7 @@ static void __init find_early_table_space(unsigned long end)
    physical memory. To access them they are temporarily mapped. */
 void __meminit init_memory_mapping(unsigned long start, unsigned long end)
 { 
-       unsigned long next
+       unsigned long next, table_rsrv_end = 0;
 
        Dprintk("init_memory_mapping\n");
 
@@ -684,7 +716,7 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
         * discovered.
         */
        if (!after_bootmem)
-               find_early_table_space(end);
+               table_rsrv_end = find_early_table_space(end);
 
        start = (unsigned long)__va(start);
        end = (unsigned long)__va(end);
@@ -712,6 +744,7 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
 
        if (!after_bootmem) {
                BUG_ON(start_pfn != table_end);
+               table_end = table_rsrv_end;
 
                /* Re-vector virtual addresses pointing into the initial
                   mapping to the just-established permanent ones. */
@@ -737,6 +770,24 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
                for (; start < end; start += PAGE_SIZE)
                        WARN_ON(HYPERVISOR_update_va_mapping(
                                start, __pte_ma(0), 0));
+
+               /* Switch to the real shared_info page, and clear the
+                * dummy page. */
+               set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
+               HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
+               memset(empty_zero_page, 0, sizeof(empty_zero_page));
+
+               /* Setup mapping of lower 1st MB */
+               for (next = 0; next < NR_FIX_ISAMAPS; next++)
+                       if (is_initial_xendomain())
+                               set_fixmap(FIX_ISAMAP_BEGIN - next, next * PAGE_SIZE);
+                       else
+                               __set_fixmap(FIX_ISAMAP_BEGIN - next,
+                                            virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
+                                            PAGE_KERNEL_RO);
+
+               BUG_ON(start_pfn > table_end);
+               table_end = start_pfn;
        }
 
        __flush_tlb_all();
@@ -815,7 +866,6 @@ size_zones(unsigned long *z, unsigned long *h,
 void __init paging_init(void)
 {
        unsigned long zones[MAX_NR_ZONES], holes[MAX_NR_ZONES];
-       int i;
 
        memory_present(0, 0, end_pfn);
        sparse_init();
@@ -823,22 +873,7 @@ void __init paging_init(void)
        free_area_init_node(0, NODE_DATA(0), zones,
                            __pa(PAGE_OFFSET) >> PAGE_SHIFT, holes);
 
-       /* Switch to the real shared_info page, and clear the
-        * dummy page. */
-       set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
-       HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
-       memset(empty_zero_page, 0, sizeof(empty_zero_page));
-
        init_mm.context.pinned = 1;
-
-       /* Setup mapping of lower 1st MB */
-       for (i = 0; i < NR_FIX_ISAMAPS; i++)
-               if (is_initial_xendomain())
-                       set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
-               else
-                       __set_fixmap(FIX_ISAMAP_BEGIN - i,
-                                    virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
-                                    PAGE_KERNEL_RO);
 }
 #endif
 
index 693adff6defc1cc4ff12ce768e9dff7bcb4d2fed..3e4d0daef97a41e5c1b55e03295b91e392f620c0 100644 (file)
@@ -53,6 +53,11 @@ enum fixed_addresses {
 #define NR_FIX_ISAMAPS 256
        FIX_ISAMAP_END,
        FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
+       __end_of_permanent_fixed_addresses,
+       /* temporary boot-time mappings, used before ioremap() is functional */
+#define NR_FIX_BTMAPS  16
+       FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
+       FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
        __end_of_fixed_addresses
 };
 
index 4788b4bcc20555e10c9f342331210f0640a18004..d92cbd5572646907338a17b3bbe3022e3e100b61 100644 (file)
@@ -150,8 +150,10 @@ static inline void __iomem * ioremap (unsigned long offset, unsigned long size)
        return __ioremap(offset, size, 0);
 }
 
-extern void *early_ioremap(unsigned long addr, unsigned long size);
-extern void early_iounmap(void *addr, unsigned long size);
+extern void *bt_ioremap(unsigned long addr, unsigned long size);
+extern void bt_iounmap(void *addr, unsigned long size);
+#define early_ioremap bt_ioremap
+#define early_iounmap bt_iounmap
 
 /*
  * This one maps high address device memory and turns off caching for that area.